<template>
  <div class="brand">
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
    >
      <router-link
        tag="div"
        class="item"
        v-for="item in list"
        :key="item.id"
        :to="`/home/brand/branddetail?id=${item.id}`"
      >
        <img :src="item.app_list_pic_url" alt="" />
        <div class="title">{{ item.name }}|{{ item.floor_price }}元起</div>
      </router-link>
    </van-list>
  </div>
</template>
<script>
import { listaction } from "@/api/home/brand";
export default {
  data() {
    return {
      total: 0, // 总页数
      page: 1, // 当前页
      list: [], // 制造商列表
      loading: false,
      finished: false,
    };
  },
  methods: {
    async onLoad() {
      // 获取制造商列表
      const { data } = await listaction({
        page: this.page,
      });
      this.total = data.total;
      this.list.push(...data);
      this.loading = false;
      this.page++;
      if (this.list.length >= this.total * 5) {
        this.finished = true;
      }
    },
    itemClick(item) {
      this.$router.push(`/home/brand/branddetail?id=${item.id}`);
    },
  },
};
</script>
<style lang="scss" scoped>
@import "./index.scss";
</style>
